import axios from "@/utils/axios";

export const getNavList = data => {
  return axios.request({
    url: "common/getLink",
    params: {
      status: data
    },
    method: "get"
  });
};
//上传图片
export const uploadImg = data => {
  return axios.request({
    url: "common/upload",
    headers: { "Content-Type": "multipart/form-data" },
    data,
    method: "post"
  });
};
//发布动态
export const publishDynamic = data => {
  return axios.request({
    url: "front/dynamic/issueDynamic",
    data,
    method: "post"
  });
};
//获取动态数据
export const getDtData = data => {
  return axios.request({
    url: "/front/index/getDynamic",
    params: data,
    method: "get"
  });
};
//获取动态详情
export const getDetailtData = data => {
  return axios.request({
    url: "/front/dynamic/dynamicDetailed",
    params: data,
    method: "get"
  });
};
//获取动态评论
export const getMaskData = data => {
  return axios.request({
    url: "front/dynamic/getDynamicEvaluate",
    params: data,
    method: "get"
  });
};
//发送动态评论
export const sendMask = data => {
  return axios.request({
    url: "front/dynamic/dynamicEvaluate",
    headers: { Authorization: "token" },
    data,
    method: "post"
  });
};
//点赞/取消点赞
export const sendZan = data => {
  return axios.request({
    url: "front/dynamic/linkDynamic",
    params: data,
    method: "get"
  });
};
//关注/取消关注
export const follow = data => {
  return axios.request({
    url: "front/dynamic/follow",
    data,
    method: "post"
  });
};
//获取主页信息
export const getIndex = data => {
  return axios.request({
    url: "front/dynamic/index",
    params: data,
    method: "get"
  });
};
//用户动态主页信息
export const getUserHomePage = data => {
  return axios.request({
    url: "front/dynamic/userHomePage",
    params: data,
    method: "get"
  });
};
//请求推荐人
export const getRecommend = data => {
  return axios.request({
    url: "front/dynamic/follow?type=recommend",
    params: data,
    method: "get"
  });
};
//用户主页---动态详细获取
export const getHomeDynamic = data => {
  return axios.request({
    url: "front/dynamic/getHomeDynamic",
    params: data,
    method: "get"
  });
};
//删除动态
export const deleteDynamic = data => {
  return axios.request({
    url: "front/dynamic/deleteDynamic",
    headers: {
      Authorization:
        "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC93d3cuYi5jb21cL2FwaVwvZnJvbnRcL3VzZXJcL2xvZ2luIiwiaWF0IjoxNTU5NTMwMDU5LCJleHAiOjE1NTk3NDYwNTksIm5iZiI6MTU1OTUzMDA1OSwianRpIjoiR1l4bXd5SVU2Q0p5ODN5NCIsInN1YiI6MSwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.IHZhW-E0ArrYGHyVEZv2qyhYECmgVDdznVUOldPw4YE\t"
    },
    params: data,
    method: "get"
  });
};
//获取动态分类信息
export const getDynamicClassify = data => {
  return axios.request({
    url: "front/dynamic/getDynamicClassify",
    headers: {
      Authorization: "Bearer token"
    },
    params: data,
    method: "get"
  });
};
//请求推荐人
export const getArticle = data => {
  return axios.request({
    url: "front/index/getDynamic?type=works",
    params: data,
    method: "get"
  });
};

export const getArticleDetail = data => {
  return axios.request({
    url: "front/index/getDynamic?type=worksDetailes",
    params: data,
    method: "get"
  });
};

export const getNoticeDetail = data => {
  return axios.request({
    url: "front/dynamic/getDynamicClassify?type=notice",
    params: data,
    method: "get"
  });
};
// 搜索
export function getSearchList({page, keyword}) {
  return axios.request({
    url: 'front/dynamic/dynamicSearch',
    params: {page, keyword},
    method: 'get'
  })
}